#include "curlWrapper.h"
#include <curl\curl.h>
#include <boost\lexical_cast.hpp>
#include <iostream>
#include <boost\algorithm\string.hpp>


curlWrapper::curlWrapper(void)
{
	//curl "http://localhost:8080/workspace1?operation=updateGraph" -d "{\"an\":{\"0\":{\"x\":\"-1.35016698073779\",\"y\":\"-1.53300531273143\",\"z\":\"0\"}}}"
	this->url = "http://localhost:8080/workspace0?operation=updateGraph";
	//this->everecptr.open("Y:\\snaptwitter1\\Iranelection\\vevents.rec",std::ios::app);
}
curlWrapper::curlWrapper(string filename)
{
	//curl "http://localhost:8080/workspace1?operation=updateGraph" -d "{\"an\":{\"0\":{\"x\":\"-1.35016698073779\",\"y\":\"-1.53300531273143\",\"z\":\"0\"}}}"
	//this->url = "http://localhost:8080/workspace0?operation=updateGraph";
	
}
void curlWrapper::setopfilename(string filename)
{
	//filename = "C:\\Documents and Settings\\abello\\Desktop\\Manifest April 20th 2011\\gephi input\\tree\\" + filename;
	//filename = "D:\\snaptwitter1\\nohashtag\\"+filename;
	this->everecptr.open(filename.c_str(),std::ios::app);
}

curlWrapper::~curlWrapper(void)
{
	this->everecptr.close();
}
void curlWrapper::loadXYZcoordinates(std::string ipfilename)
{
	std::ifstream ipfilepointer;
	ipfilepointer.open(ipfilename.c_str(),std::ifstream::in);
	string linetoread;
	while(getline(ipfilepointer,linetoread))
	{
		vector<std::string> parts;
		boost::split(parts,linetoread,boost::is_any_of(" "));
		XYZcoord tempcords;
		tempcords.X = boost::lexical_cast<float>(parts[1]);
		tempcords.Y = boost::lexical_cast<float>(parts[2]);
		tempcords.Z =0.0;
		this->nodeXYZ.insert(pair<int,XYZcoord>(boost::lexical_cast<int>(parts[0]),tempcords));
	}
	ipfilepointer.close();
	return;
}
string curlWrapper::modifySize(string linetoprocess)
{
	return "none";
}
void curlWrapper::closeOfStream()
{
	this->everecptr.close();
}
void curlWrapper::read_events_from_file(std::string ipfilename)
{
	std::ifstream ipfilepointer;
	ipfilepointer.open(ipfilename.c_str(),std::ifstream::in);
	string linetoread;
	//const char* post_field;
	int line_count = 0;
	std::string final_string;
	while(getline(ipfilepointer,linetoread))
	{
		const char* post_field;
		
		std::string stringtoappend;
		if ( linetoread.find("\"an\"") != std::string::npos)
		{
			vector<std::string> parts;
			boost::split(parts,linetoread,boost::is_any_of("*"));
			int node_id = boost::lexical_cast<int>(parts[0]);
			/*map<int,XYZcoord>::iterator xy_itr= this->nodeXYZ.find(node_id);
			string linetoappend = ",\"x\":\"" + boost::lexical_cast<std::string>(xy_itr->second.X + 0.1)+"\",\"y\":\"";
			linetoappend+= boost::lexical_cast<std::string>(xy_itr->second.Y+0.1)+"\"}}}";
			boost::trim_right_if(parts[1],boost::is_any_of("}"));*/
			stringtoappend = parts[1];//+linetoappend;
			//post_field = final_string.c_str();

		}
		else
		{
			//post_field = linetoread.c_str();
			stringtoappend = linetoread;
		}
		//char *final_post_field = *post_field;
		if ( line_count<2000)
		{
			++line_count;
			final_string = final_string+stringtoappend+"\r";
			continue;
		}
		final_string+=stringtoappend;
		line_count = 0;
		post_field = final_string.c_str();
	
		char final_post[65536] = "";
		//strcpy(final_post,post_field);
		strcat(final_post,post_field);
		CURL *curl;
		curl = curl_easy_init();
		CURLcode res;
		static char errorBuffer[CURL_ERROR_SIZE];
		curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
		curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
		curl_easy_setopt(curl,CURLOPT_POSTFIELDS,final_post);
		res = curl_easy_perform(curl);
		cout<<res<<endl<<errorBuffer<<endl;
		
		int i = 0;
		/*do{
			i++;
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,"");
			res = curl_easy_perform(curl);
		}while(i <1000 );*/
		final_string = "";
		curl_easy_cleanup(curl);	
	}
	//final_string+=stringtoappend;
	boost::trim_right_if(final_string,boost::is_any_of("\r"));
	const char* post_field = final_string.c_str();
	char final_post[65536] = "";
	//strcpy(final_post,post_field);
	strcat(final_post,post_field);
	CURL *curl;
	curl = curl_easy_init();
	CURLcode res;
	static char errorBuffer[CURL_ERROR_SIZE];
	curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
	curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
	curl_easy_setopt(curl,CURLOPT_POSTFIELDS,final_post);
	res = curl_easy_perform(curl);
	cout<<res<<endl<<errorBuffer<<endl;
	final_string = "";
	curl_easy_cleanup(curl);	
	return;

}
void curlWrapper ::change_node(int node_id,map<string,string> src_prop)
{
	/*CURL *curl;
	curl = curl_easy_init();
	CURLcode res;
	static char errorBuffer[CURL_ERROR_SIZE];
	curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
	curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");*/
	/*string postfield = "{\"cn\":{\""+ boost ::lexical_cast<std::string>(node_id) + "\":{";
	postfield+= "\"size\":\"" + size +"\"}}}";
	char SC[4096] = "";
	std::strcpy(SC,postfield.c_str());
	curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
	res=curl_easy_perform(curl);*/
	string postfield = "{\"cn\":{\""+ boost ::lexical_cast<std::string>(node_id) + "\":{";
	map<string,string>::iterator src_prop_itr;
	for ( src_prop_itr = src_prop.begin();src_prop_itr != src_prop.end();src_prop_itr++)
	{
		if ( (src_prop_itr->first.compare("chi_val")==0 )|| (src_prop_itr->first.compare("freq")==0 ) || (src_prop_itr->first.compare("sbp")==0 ))
			postfield += "\""+src_prop_itr->first+"\":"+src_prop_itr->second+",";
		else
			postfield += "\""+src_prop_itr->first+"\":\""+src_prop_itr->second+"\",";
		
	}
	boost::trim_right_if(postfield,boost::is_any_of(","));
	postfield+="}}}";
	/*char SC[4096] = "";
	strcpy(SC,postfield.c_str());
	curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
	res=curl_easy_perform(curl);*/
	this->everecptr<<postfield<<endl;
	
	return;

	
}

void curlWrapper::change_edge(int src,int tar,map<string,string> edge_properties)
{
	string edge_id = boost::lexical_cast<std::string>(src)+"-"+boost::lexical_cast<std::string>(tar);
	string postfield = "{\"ce\":{\""+ edge_id + "\":{";
	map<string,string>::iterator edge_prop_itr;
	for ( edge_prop_itr = edge_properties.begin();edge_prop_itr != edge_properties.end();edge_prop_itr++)
	{
		if ( (edge_prop_itr->first.compare("chi_val")==0) || (edge_prop_itr->first.compare("freq")==0) ||(edge_prop_itr->first.compare("sbp")==0))
				postfield += "\""+edge_prop_itr->first+"\":"+edge_prop_itr->second+",";
		else
			postfield += "\""+edge_prop_itr->first+"\":\""+edge_prop_itr->second+"\",";
	}
	boost::trim_right_if(postfield,boost::is_any_of(","));
	postfield+="}}}";
	this->everecptr<<postfield<<endl;
	
	return;
}

void curlWrapper::add_edge(int src,map<string,string> src_properties,int tar,map<string,string> tar_properties,map<string,string> edge_properties)
{
	/*CURL *curl;
	curl = curl_easy_init();*/
	string edge_id = boost::lexical_cast<std::string>(src)+"-"+boost::lexical_cast<std::string>(tar);
	if ( this->nodesadded.find(src) != this->nodesadded.end())
	{
		this->change_node(src,src_properties);
	}
	if ( this->nodesadded.find(tar) != this->nodesadded.end())
	{
		this->change_node(tar,tar_properties);
	}
	if (this->edges_present.find(edge_id) != this->edges_present.end())
	{
		//call change node here;
		/*this->change_node(src,src_properties.begin()->second);
		this->change_node(tar,tar_properties.begin()->second);*/
		this->change_edge(src,tar,edge_properties);
		return;
	}
	/*CURLcode res;
	
	static char errorBuffer[CURL_ERROR_SIZE];
	if ( curl)*/
	{
		//curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
		if (this->nodesadded.find(src) == this->nodesadded.end())
		{
	
			//curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
			string postfield = "{\"an\":{\""+ boost ::lexical_cast<std::string>(src) + "\":{";
			map<string,string>::iterator src_prop_itr;
			for ( src_prop_itr = src_properties.begin();src_prop_itr != src_properties.end();src_prop_itr++)
			{
				if (( src_prop_itr->first.compare("chi_val") == 0 )|| (src_prop_itr->first.compare("ver_freq") == 0))
					postfield += "\""+src_prop_itr->first+"\":"+src_prop_itr->second+",";
				else
					postfield += "\""+src_prop_itr->first+"\":\""+src_prop_itr->second+"\",";
					

			}
			boost::trim_right_if(postfield,boost::is_any_of(","));
			postfield+="}}}";
			/*char SC[4096] = "";
			strcpy(SC,postfield.c_str());
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
			res=curl_easy_perform(curl);
			cout <<res<<endl<<errorBuffer;*/
			this->nodesadded.insert(pair<int,bool>(src,true));
			this->everecptr<<src<<"*"<<postfield<<endl;
			
		}
		/*src_properties.find("Label")->second = "";
		this->change_node(src,src_properties);*/
		if ( this->nodesadded.find(tar) == this->nodesadded.end())
		{
			//curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
			string postfield = "{\"an\":{\""+ boost ::lexical_cast<std::string>(tar) + "\":{";
			map<string,string>::iterator tar_prop_itr;
			for ( tar_prop_itr = tar_properties.begin();tar_prop_itr != tar_properties.end();tar_prop_itr++)
			{
				if((tar_prop_itr->first.compare("chi_val") == 0) || (tar_prop_itr->first.compare("ver_freq") ==0))
 					postfield += "\""+tar_prop_itr->first+"\":"+tar_prop_itr->second+",";
				else
					postfield += "\""+tar_prop_itr->first+"\":\""+tar_prop_itr->second+"\",";

			}
			boost::trim_right_if(postfield,boost::is_any_of(","));
			postfield+="}}}";
			/*char SC[4096] = "";
			strcpy(SC,postfield.c_str());
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
			res=curl_easy_perform(curl);*/
			//cout <<res<<endl<<errorBuffer;
			this->nodesadded.insert(pair<int,bool>(tar,true));
			this->everecptr<<tar<<"*"<<postfield<<endl;
		}
		
		/*tar_properties.find("Label")->second ="";
		this->change_node(tar,tar_properties);*/
	
		//curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
		string postfield ="{\"ae\":{\"" + edge_id +"\":{";
		map<string,string>::iterator edge_prop_itr;
		for ( edge_prop_itr = edge_properties.begin();edge_prop_itr != edge_properties.end();edge_prop_itr++)
		{
			postfield += "\""+ edge_prop_itr->first+"\":\""+edge_prop_itr->second+"\",";
		}
		//boost::trim_right_if(postfield,boost::is_any_of(","));
		postfield+="\"directed\":false}}}";
		//char SE[4096] = "";
		//strcpy(SE,postfield.c_str());
		//curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SE);
		////commenting to prevent adding edges.
		//res = curl_easy_perform(curl);
		//cout <<errorBuffer;
		this->everecptr<<postfield<<endl;
		this->edges_present.insert(pair<string,bool>(edge_id,true));
	}
	//delete curl;
	//curl_easy_cleanup(curl);
	//delete curl;
	return;
}
/**************************************************************************************************
Funtion: add_edge(int src,int tar,float weight).
Description: Depreciated. Do not use. Use the newer version.
***************************************************************************************************/

void curlWrapper::add_edge(int src,int tar,float weight)
{
	CURL *curl;
	curl = curl_easy_init();
	string edge_id_1 = boost::lexical_cast<std::string>(src)+"-"+boost::lexical_cast<std::string>(tar);
	if (this->edges_present.find(edge_id_1) != this->edges_present.end())
		return;
	string edge_weight = boost::lexical_cast<std::string>(weight);
	CURLcode res;
	typedef std::basic_string<char> myString;
	char src_string[10];
	char tar_string[10];
	const char* wt_string = edge_weight.c_str();
	itoa(src,src_string,10);
	itoa(tar,tar_string,10);
	//itoa(weight,wt_string,10);
	char edge_id[1024] = "";
	char ch[2] ="-";
	strcat(edge_id,src_string);
	strcat(edge_id,ch);
	strcat(edge_id,tar_string);
	
	static char errorBuffer[CURL_ERROR_SIZE];
	if ( curl)
	{
		curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
		if (this->nodesadded.find(src) == this->nodesadded.end())
		{
			//myString url_to_send = this->url;	
			//string url_to_send = this->url;// + " {\"an\":{\""+ boost ::lexical_cast<std::string>(src) + "\":{}}}";
			curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
			//myString postfield = "{\"an\":{\""+ boost ::lexical_cast<std::string>(src) + "\":{}}}";
			char SC[4096] = "{\"an\":{\"";
			char DC[4096] = "\":{";
			map<int,XYZcoord>::iterator xy_itr= this->nodeXYZ.find(src);
			string linetoappend = "\"x\":\"" + boost::lexical_cast<std::string>(xy_itr->second.X)+"\",\"y\":\"";
			linetoappend+= boost::lexical_cast<std::string>(xy_itr->second.Y)+"\",\"size\":\"100\"}}}";
			const char* XYstring = linetoappend.c_str();

			
			strcat(SC,src_string);
			strcat(SC,DC);
			strcat(SC,XYstring);
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
			res=curl_easy_perform(curl);
			//cout <<res<<endl<<errorBuffer;
			this->nodesadded.insert(pair<int,bool>(src,true));
			this->everecptr<<src<<"*"<<SC<<endl;
			
		}
		if ( this->nodesadded.find(tar) == this->nodesadded.end())
		{
			//string url_to_send = this->url + " {\"an\":{\""+ boost ::lexical_cast<std::string>(tar) + "\":{}}}";
			char SC[4096] = "{\"an\":{\"";
			char DC[4096] = "\":{";
			char src_string[10];
			map<int,XYZcoord>::iterator xy_itr= this->nodeXYZ.find(tar);
			string linetoappend = "\"x\":\"" + boost::lexical_cast<std::string>(xy_itr->second.X)+"\",\"y\":\"";
			linetoappend+= boost::lexical_cast<std::string>(xy_itr->second.Y)+"\",\"size\":\"100\"}}}";
			const char* XYstring = linetoappend.c_str();

			strcat(SC,tar_string);
			strcat(SC,DC);
			strcat(SC,XYstring);
			curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
			curl_easy_perform(curl);
			this->nodesadded.insert(pair<int,bool>(tar,true));
			this->everecptr<<tar<<"*"<<SC<<endl;
		}
		//string url_add_edge = this->url+" {\"ae\":{\"" + edge_id +"\":{\"source\":\"" +  boost ::lexical_cast<std::string>(src) +"\",\"target\":\"" + boost ::lexical_cast<std::string>(tar) +"\",\"directed\":false}}}";
		curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
		char SE[4096] = "{\"ae\":{\"";
		char sourcestr[1024] = "\":{\"source\":\"";
		char targetstr[1024] = "\",\"target\":\"";
		char weightstr[1024] = "\",\"weight\":\"";
		char directedstr[1024] = "\",\"directed\":false}}}";
		strcat(SE,edge_id);
		strcat(SE,sourcestr);
		strcat(SE,src_string);
		strcat(SE,targetstr);
		strcat(SE,tar_string);
		strcat(SE,weightstr);
		strcat(SE,wt_string);
		strcat(SE,directedstr);
		curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SE);
		//curl_easy_perform(curl);
		this->everecptr<<SE<<endl;
		this->edges_present.insert(pair<string,bool>(edge_id,true));
	}
	return;
}

void curlWrapper ::loadtimesorted(std::string ipfilename)
{
	std::ifstream ipfilepointer;
	ipfilepointer.open(ipfilename.c_str(),ifstream::in);
	string linetoread;
	map<string,bool> temp_edges_present;
	while(getline(ipfilepointer,linetoread))
	{
		map<string,bool> temp_edges_to_be_added;
		vector<string> remove_time;
		boost::split(remove_time,linetoread,boost::is_any_of(":"));
		vector<string> edges;
		boost::split(edges,remove_time[1],boost::is_any_of(" "));
		for(int i =0 ; i< edges.size();i++)
		{
			if(edges[i] =="")
				continue;
			/*vector<string> vertices;
			boost::split(vertices,edges[i],boost::is_sny_of",");
			int src= boost::lexical_cast<int>(vertices[0]);
			int tar = boost::lexical_cast<int>(vertices[1]);*/
			boost::replace_first(edges[i],",","-");
				
			temp_edges_to_be_added.insert(pair<string,bool>(edges[i],true));
			
		}
		map<string,bool>::iterator edges_present_itr;
		//for(edges_present_itr = temp_edges_present.begin();edges_present_itr != temp_edges_present.end();++edges_present_itr)
		//{
		//	if ( temp_edges_to_be_added.find(edges_present_itr->first) == temp_edges_to_be_added.end())
		//	{
		//		vector<string> vertices;
		//		boost::split(vertices,edges_present_itr->first,boost::is_any_of("-"));
		//		int src= boost::lexical_cast<int>(vertices[0]);
		//		int tar = boost::lexical_cast<int>(vertices[1]);
		//		this->remove_edge(src,tar);
		//		
		//	}
		//	
		//}
		map<string,bool>::iterator edges_to_be_added_itr;
		temp_edges_present.clear();
		for ( edges_to_be_added_itr=temp_edges_to_be_added.begin();edges_to_be_added_itr!=temp_edges_to_be_added.end();edges_to_be_added_itr++)
		{
				vector<string> vertices;
				boost::split(vertices,edges_to_be_added_itr->first,boost::is_any_of("-"));
				int src= boost::lexical_cast<int>(vertices[0]);
				int tar = boost::lexical_cast<int>(vertices[1]);
				this->add_edge(src,tar,10.0);
				temp_edges_present.insert(pair<string,bool>(edges_to_be_added_itr->first,true));
		}
		int j =0;
		CURL *curl;
		curl = curl_easy_init();
		curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
		do{
			j++;
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,"");
			curl_easy_perform(curl);
		}while(j <10 );
			

	}
	return;

}
void curlWrapper::add_node(int node_id,map<string,string> src_prop)
{
	/*CURL *curl;
	curl = curl_easy_init();
	CURLcode res;
	
	static char errorBuffer[CURL_ERROR_SIZE];
	if ( curl)*/
	{
		//curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorBuffer);
		if (this->nodesadded.find(node_id) == this->nodesadded.end())
		{
	
			//curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
			string postfield = "{\"an\":{\""+ boost ::lexical_cast<std::string>(node_id) + "\":{";
			map<string,string>::iterator src_prop_itr;
			for ( src_prop_itr = src_prop.begin();src_prop_itr != src_prop.end();src_prop_itr++)
			{
				if ( (src_prop_itr->first.compare("chi_val")==0 )|| (src_prop_itr->first.compare("freq")==0 ) ||(src_prop_itr->first.compare("sbp")==0 ))
					postfield += "\""+src_prop_itr->first+"\":"+src_prop_itr->second+",";
				else
					postfield += "\""+src_prop_itr->first+"\":\""+src_prop_itr->second+"\",";

			}
			boost::trim_right_if(postfield,boost::is_any_of(","));
			postfield+="}}}";
			/*char SC[4096] = "";
			strcpy(SC,postfield.c_str());
			curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SC);
			res=curl_easy_perform(curl);*/
			this->nodesadded.insert(pair<int,bool>(node_id,true));
			this->everecptr<<node_id<<"*"<<postfield<<endl;
			
		}
		else
		{
			this->change_node(node_id,src_prop);
		}
	
	}
	//curl_easy_cleanup(curl);
	return;
}
int curlWrapper ::remove_edge(int src, int tar)
{
	string edge_id_1 = boost::lexical_cast<string>(src)+"-"+boost::lexical_cast<string>(tar);
	string edge_id_2 = boost::lexical_cast<string>(tar)+"-"+boost::lexical_cast<string>(src);
	map<string,bool>::iterator edge_itr_1 = this->edges_present.find(edge_id_1);
	map<string,bool>::iterator edge_itr_2 = this->edges_present.find(edge_id_2);
	if ((  edge_itr_1== this->edges_present.end()) && (edge_itr_2== this->edges_present.end()))
		return 0;
	//CURL *curl;
	//curl = curl_easy_init();
	////string edge_id = boost::lexical_cast<std::string>(src)+boost::lexical_cast<std::string>(tar);
	//char src_string[10];
	//char tar_string[10];
	//itoa(src,src_string,10);
	//itoa(tar,tar_string,10);
	//char edge_id[1024] = "";
	//char ch[2] ="-";
	//strcat(edge_id,src_string);
	//strcat(edge_id,ch);
	//strcat(edge_id,tar_string);
	//if ( curl)
	//{
	//	//string url_remove_edge = this->url + " {\"de\": {\"" + edge_id+"\":{}}}";
	//	curl_easy_setopt(curl,CURLOPT_URL,"http://localhost:8080/workspace0?operation=updateGraph");
	//	char SE[4096] = "{\"de\": {\"";
	//	char DE[1024] = "\":{}}}";
	//	strcat(SE,edge_id);
	//	strcat(SE,DE);
	//	curl_easy_setopt(curl,CURLOPT_POSTFIELDS,SE);
	//	cout<<curl_easy_perform(curl);
	//	this->everecptr<<SE<<endl;
	//}
	string postfield = "";
	if ( edge_itr_1 != this->edges_present.end())
	{
		postfield = "{\"de\": {\"" + edge_id_1 + "\":{}}}";
		this->edges_present.erase(edge_itr_1);
	}
	else
	{
		postfield = "{\"de\": {\"" + edge_id_2 + "\":{}}}";
		this->edges_present.erase(edge_itr_2);
	}
	this->everecptr<<postfield<<endl;
	
	
	return 1;
}


